#pragma once
#include <GL/glew.h>
#include "Vector4D.h"
#include "Point3D.h"
//#include <GL/glut.h>

class BSplineSurface 
{
private:
	float * v_knots;
	float * u_knots;

	int v_knots_n;
	int u_knots_n;
	int m;
	int n;
	Point3D ** values;

	GLuint buffID;
	int buffSize;

	double divide(double a,double b);
	double getSplineValue(float t,int i,int n,const float * knots);
	void fillKnots(float *& knots,int n);
	void fillSurfaceValues();
public:
	BSplineSurface(int m,int n,int pointsM,int pointsN);
	~BSplineSurface(void);
	void addPoint(int m,int n,Point3D p);
	float getVMaxGenerationValue();
	float getUMaxGenerationValue();
	//Vector4D& getDerivativeAt(float t,float * knots);
	void draw();
	Point3D getPointAt(float u,float v);
};

